<template>
  <jke-modal
      :visible.sync="jkeForm.visible"
      :width="1200"
      :title="jkeForm.title"
      :fullscreen.sync="jkeForm.fullscreen"
      :switchFullscreen="jkeForm.switchFullscreen"
    >
    <!--  -->
    <crumbs
      @goBack="goBack"
      :superiorMenu="['生产设置', '计件单价']"
      marginBottom="10px"
      :currentMenu="jkeForm.title"
    ></crumbs>
    <div class="form-body">
      <a-card title="基本信息" :bordered="false">
        <a-form :form="form" @submit="handleSubmit" layout="vertical">
          <a-form-item label="生产工序" required>
            <a-input placeholder="请选择" :read-only="true" @click="openItProcess" v-decorator="['processName', { rules: [{ required: true, message: '请选择生产工序' }] }]" :class="processValue? 'has-value' : ''">
              <a-icon slot="suffix" type="down" style="color: #cdcdcd; font-size: 12px" class="down-icon" />
                <a-icon slot="suffix" type="close-circle" theme="filled" class="close-icon" @click="getSelectValueProcess(false, '', [])" />
            </a-input>
            <tableSelect ref="tableSelectProcess" @getSelectValue="getSelectValueProcess" :key="indexProcess">
              <div slot="head">
                <div class="uni-card" style="background: #fff">
                  <a-form-model ref="ruleForm" layout="inline" :model="filterFormProcess">
                    <a-form-model-item label="工序编号">
                      <a-input v-model="filterFormProcess.processCode" placeholder="请输入" />
                    </a-form-model-item>
                    <a-form-model-item label="工序名称">
                      <a-input v-model="filterFormProcess.processName" placeholder="请输入" />
                    </a-form-model-item>
                    <a-form-model-item>
                      <a-button @click="searchProcess" type="primary"> 搜索 </a-button>
                      <a-button style="margin-left: 10px" @click="searchResetProcess">重置</a-button>
                    </a-form-model-item>
                  </a-form-model>
                </div>
              </div>
            </tableSelect>
          </a-form-item>
          <a-form-item label="报工单位">
            <a-input
              disabled
              v-decorator="['processWorkUnitText']"
              placeholder="请选择生产工序"
            />
          </a-form-item>
          <div class="ant-form-item"></div>
        </a-form>
        <a-form :form="form" @submit="handleSubmit" layout="vertical">
          <a-form-item label="生产产品" required>
            <a-input placeholder="请选择" :read-only="true" @click="showSelect" v-decorator="['goodsName', { rules: [{ required: true, message: '请选择生产产品' }] }]" :class="goodsName? 'has-value' : ''">
              <a-icon slot="suffix" type="down" style="color: #cdcdcd; font-size: 12px" class="down-icon" />
              <a-icon slot="suffix" type="close-circle" theme="filled" class="close-icon" @click="getSelectValue(false, '', [])" />
            </a-input>
            <goodsTableSelect
              ref="tableSelect"
              @getSelectValue="getSelectValue"
              :key="selectIndex"
            />
          </a-form-item>
          <a-form-item label="产品规格">
            <a-input disabled v-decorator="['spec']" placeholder="请选择生产产品" />
          </a-form-item>
          <a-form-item label="基本单位">
            <a-input disabled v-decorator="['basicUnitText']" placeholder="请选择生产产品" />
          </a-form-item>
        </a-form>
      </a-card>
      <a-card title="计件单价信息" :bordered="false" style="margin-top: 12px">
        <a-form :form="form" @submit="handleSubmit" layout="vertical">
          <a-form-item label="计价方式">
            <a-radio-group v-decorator="['type']" @change="changeRadio">
              <a-radio value="regular">
                常规计价
              </a-radio>
              <a-radio value="planned_output">
                计划产量计价
              </a-radio>
            </a-radio-group>
          </a-form-item>
        </a-form>
        <a-form :form="form" @submit="handleSubmit" layout="vertical" v-if="showRegular">
          <a-form-item label="合格品单价（元/报工单位）">
            <a-input @input="(e) => formPrice(e, 1)" v-decorator="['qualifiedPrice', { rules: [{ required: true, message: '请输入合格品单价' }] }]" placeholder="请输入" />
          </a-form-item>
          <a-form-item label="不合格品单价（元/报工单位）">
            <a-input @input="(e) => formPrice(e, 2)" v-decorator="['notQualifiedPrice', { rules: [{ required: true, message: '请输入不合格品单价' }] }]" placeholder="请输入" />
          </a-form-item>
          <div class="ant-form-item"></div>
        </a-form>
        <div v-else>
          <a-button type="primary" style="margin-bottom:24px" @click="handleAdd"> +新增 </a-button>
          <a-table
              row-key="id"
              size="middle"
              :hideDefaultSelections="false"
              :columns="priceColumns"
              :dataSource="priceList"
              :pagination="false"
            >
              <span slot="numTitle">
                <span style="color:red">*</span>计划生产区间
                <a-tooltip>
                  <template slot="title"> 区间取值为大于开始数字，小于等于结束数字 </template>
                  <a-icon type="question-circle" />
                </a-tooltip>
              </span>
              <span slot="qTitle">
                <span style="color:red">*</span>合格品单价（元/报工单位）
              </span>
              <span slot="nqTitle">
                <span style="color:red">*</span>不合格品单价（元/报工单位）
              </span>
              <span slot="startNum" slot-scope="text, record, index">
                <a-input @input="(e) => tableInput(e, 1, index)" @blur="(e) => tableNum(e, 1, index)" v-model="record.startNum" placeholder="请输入" style="width:120px" /> ~ <a-input @input="(e) => tableInput(e, 2, index)" @blur="(e) => tableNum(e, 2, index)" v-model="record.endNum" placeholder="请输入" style="width:120px" />
              </span>
              <span slot="qualifiedPrice" slot-scope="text, record, index">
                <a-input @input="(e) => tablePrice(e, 1, index)" v-model="record.qualifiedPrice" placeholder="请输入" />
              </span>
              <span slot="notQualifiedPrice" slot-scope="text, record, index">
                <a-input @input="(e) => tablePrice(e, 2, index)" v-model="record.notQualifiedPrice" placeholder="请输入" />
              </span>
              <span slot="actions" slot-scope="text, record, index">
                <span :class="setClass(index)" @click="deleteRecord(index)">删除</span>
              </span>
            </a-table>
        </div>
      </a-card>
    </div>

    <div class="footer-submit form-footer">
      <a-button type="primary" :loading="loadingSubmit" @click="handleSubmit"> 提交 </a-button>
    </div>
  </jke-modal>
</template>
<script>
import crumbs from '@/components/crumbs.vue'
import FileUpload from '@/components/fileActions/FileUpload.vue'
import { API } from '@/api/requestFzs'
import { clearPrice, fourFloatNum, validateDuplicateValue, clearNoNum } from '@/utils/util'
import tableSelect from '@/components/tableSelect'
import goodsTableSelect from '@/components/goodsTableSelect'
export default {
  data() {
    return {
      jkeForm: {
        title: '新建',
        visible: false,
        fullscreen: true,
        switchFullscreen: true,
      },
      validateDuplicateValue,
      formLayout: 'horizontal',
      form: this.$form.createForm(this, { name: 'coordinated' }),
      attachment: '',
      submitApi: API.messProductProcessPriceAdd,
      isEdit: false,
      queryId: '',
      loadingSubmit: false,
      typeList: [],
      processName: '',
      //下拉改弹窗结束
      //下拉改弹窗
      indexProcess: 0,
      columnsProcess: [
        {
          title: '工序编号',
          dataIndex: 'processCode',
          width: 180,
          ellipsis: true,
        },
        {
          title: '工序名称',
          dataIndex: 'processName',
          key: 'processName',
          width: 180,
          ellipsis: true,
        },
        {
          title: '报工单位',
          dataIndex: 'processWorkUnitText',
          width: 180,
          key: 'processWorkUnitText',
          ellipsis: true,
        },
        {
          title: '工序要求',
          dataIndex: 'processRequire',
          width: 180,
          key: 'processRequire',
          ellipsis: true,
        },
      ],
      processValue: '',
      processText: '',
      filterFormProcess: {
        processCode: '', //工序编号
        processName: '', //工序名称
      },
      selectIndex: 0,
      selectColumns: [
        {
          title: '物品编号',
          width: 180,
          ellipsis: true,
          dataIndex: 'goodsCode',
          searchKey: 'goodsCode',
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'goodsCode',
          },
        },
        {
          title: '物品名称',
          width: 180,
          ellipsis: true,
          dataIndex: 'goodsName',
          searchKey: 'goodsName',
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'goodsName',
          },
        },
        {
          title: '规格',
          width: 100,
          ellipsis: true,
          dataIndex: 'spec',
          searchKey: 'spec',
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'spec',
          },
        },
        {
          title: '物品类型',
          width: 100,
          ellipsis: true,
          dataIndex: 'typeText',
          searchKey: 'type',
          type: 'select',
          scopedSlots: {
            filterDropdown: 'selectDropdown',
            filterIcon: 'selectIcon',
            customRender: 'typeText',
          },
        },
        {
          title: '物品分类',
          width: 100,
          ellipsis: true,
          dataIndex: 'categoryText',
          searchKey: 'category',
          type: 'tree',
          scopedSlots: {
            filterDropdown: 'selectDropdown',
            filterIcon: 'selectIcon',
            customRender: 'categoryText',
          },
        },
      ],
      goodsId: '',
      goodsName: '',
      filterForm: {},
      showRegular: true,
      priceList: [
        {
          startNum: '',
          endNum: '',
          qualifiedPrice: '0',
          notQualifiedPrice: '0',
        }
      ],
      priceColumns: [
        {
          title: '序号',
          width: 50,
          customRender: (text, record, index) => `${index + 1}`,
        },
        {
          dataIndex: 'startNum',
          width: 180,
          ellipsis: true,
          slots: { title: 'numTitle'},
          scopedSlots: { customRender: 'startNum' },
        },
        {
          dataIndex: 'qualifiedPrice',
          width: 180,
          ellipsis: true,
          slots: { title: 'qTitle'},
          scopedSlots: { customRender: 'qualifiedPrice' },
        },
        {
          dataIndex: 'notQualifiedPrice',
          width: 180,
          ellipsis: true,
          slots: { title: 'nqTitle'},
          scopedSlots: { customRender: 'notQualifiedPrice' },
        },
        {
          fixed: 'right',
          title: '操作',
          width: 50,
          dataIndex: 'actions',
          ellipsis: true,
          scopedSlots: { customRender: 'actions' },
        },
      ],
    }
  },
  components: {
    FileUpload,
    crumbs,
    tableSelect,
    goodsTableSelect
  },
  methods: {
    formPrice(e, key) {
      let num = clearPrice(e.target.value)
      if (key == 1) {
        this.form.setFieldsValue({
          'qualifiedPrice': num,
        })
      } else {
        this.form.setFieldsValue({
          'notQualifiedPrice': num,
        })
      }
    },
    tablePrice(e, key, index) {
      let num = clearPrice(e.target.value)
      if (key == 1) {
        this.priceList[index].qualifiedPrice = num
      } else {
        this.priceList[index].notQualifiedPrice = num
      }
    },
    tableInput(e, key, index) {
      let num = clearNoNum(e.target.value)
      if (key == 1) {
        this.priceList[index].startNum = num
      } else {
        this.priceList[index].endNum = num
      }
    },
    tableNum(e, key, index) {
      let num = null
      if (!!e.target.value || e.target.value === 0) {
        num = Number(fourFloatNum(e.target.value))
      } else {
        num = ''
        return
      }
      let firstEnd = Number(this.priceList[index].endNum)
      if (key == 1) { // 开始数字限制
        if (index > 0) { // 列表第二行往下（包含第二行）开始数字限制
          let before_end = this.priceList[index - 1] ? this.priceList[index - 1].endNum ? Number(this.priceList[index - 1].endNum) : '' : ''
          let before_start = this.priceList[index - 1] ? this.priceList[index - 1].startNum ? Number(this.priceList[index - 1].startNum) : '' : ''
          let next_end = this.priceList[index + 1] ? this.priceList[index + 1].endNum ? Number(this.priceList[index + 1].endNum) : '' : ''
          let next_start = this.priceList[index + 1] ? this.priceList[index + 1].startNum ? Number(this.priceList[index + 1].startNum) : '' : ''
          let currnt_end = this.priceList[index].endNum ? Number(this.priceList[index].endNum) : ''
          // 相邻区间不能设置相同区间数字
          if (!!before_start || before_start === 0 && !!before_end || before_end === 0 && !!currnt_end || currnt_end === 0) {
            if (num == before_start && currnt_end == before_end) {
              this.priceList[index].startNum = ''
              this.$antdMessage.info('不能与上一个区间完全相等，请重新输入')
              return
            }
            if (num == next_start && currnt_end == next_end) {
              this.priceList[index].startNum = ''
              this.$antdMessage.info('不能与下一个区间完全相等，请重新输入')
              return
            }
          }
          // 不能小于上一个结束数字
          if (num < before_end) {
            this.priceList[index].startNum = ''
            this.$antdMessage.info('不能小于上一个结束数字')
            return
          }
          // 不能大于结束数字
          if (firstEnd && num > firstEnd) {
            this.priceList[index].startNum = ''
            this.$antdMessage.info('不能大于结束数字')
            return
          }
        } else { // 列表第一行的开始数字限制
          // 不能大于结束数字
          let next_end = this.priceList[index + 1] ? this.priceList[index + 1].endNum ? Number(this.priceList[index + 1].endNum) : '' : ''
          let next_start = this.priceList[index + 1] ? this.priceList[index + 1].startNum ? Number(this.priceList[index + 1].startNum) : '' : ''
          let currnt_end = this.priceList[index].endNum ? Number(this.priceList[index].endNum) : ''
          if (!!next_end || next_end === 0 && !!next_start || next_start === 0 && !!currnt_end || currnt_end === 0) {
            if (num == next_start && currnt_end == next_end) {
              this.priceList[index].startNum = ''
              this.$antdMessage.info('不能与下一个区间完全相等，请重新输入')
              return
            }
          }
          if (firstEnd && num > firstEnd) {
            console.log(num, '>', firstEnd);
            this.priceList[index].startNum = ''
            this.$antdMessage.info('不能大于结束数字')
            return
          }
        }
      } else { // 结束数字限制
        if (index > 0) { // 列表第二行往下（包含第二行）开始数字限制
          let before_end = this.priceList[index - 1] ? this.priceList[index - 1].endNum ? Number(this.priceList[index - 1].endNum) : '' : ''
          let before_start = this.priceList[index - 1] ? this.priceList[index - 1].startNum ? Number(this.priceList[index - 1].startNum) : '' : ''
          let next_end = this.priceList[index + 1] ? this.priceList[index + 1].endNum ? Number(this.priceList[index + 1].endNum) : '' : ''
          let next_start = this.priceList[index + 1] ? this.priceList[index + 1].startNum ? Number(this.priceList[index + 1].startNum) : '' : ''
          let currnt_start = this.priceList[index].startNum ? Number(this.priceList[index].startNum) : ''
          // 相邻区间不能设置相同区间数字
          console.log('you',currnt_start);
          if (!!before_start || before_start === 0 && !!before_end || before_end === 0 && !!currnt_start || currnt_start === 0) {
            console.log('进来了');
            if (num == before_end && currnt_start == before_start) {
              this.priceList[index].endNum = ''
              this.$antdMessage.info('不能与上一个区间完全相等，请重新输入')
              return
            }
            if (num == next_end && currnt_start == next_start) {
              this.priceList[index].endNum = ''
              this.$antdMessage.info('不能与下一个区间完全相等，请重新输入')
              return
            }
          }
        } else {
          let next_end = this.priceList[index + 1] ? this.priceList[index + 1].endNum ? Number(this.priceList[index + 1].endNum) : '' : ''
          let next_start = this.priceList[index + 1] ? this.priceList[index + 1].startNum ? Number(this.priceList[index + 1].startNum) : '' : ''
          let currnt_start = this.priceList[index].endNum ? Number(this.priceList[index].endNum) : ''
          if (!!next_end || next_end === 0 && !!next_start || next_start === 0 && !!currnt_start || currnt_start === 0) {
            if (num == next_start && currnt_start == next_end) {
              this.priceList[index].endNum = ''
              this.$antdMessage.info('不能与下一个区间完全相等，请重新输入')
              return
            }
          }
        }
        let numrt1 = this.priceList[index].startNum
        numrt1 = Number(numrt1)
        if (this.priceList[index+1] && this.priceList[index+1].startNum) { // 存在下一行且下一行存在开始数字时的结束数字限制
          let numrt2 = this.priceList[index+1].startNum
          numrt2 = Number(numrt2)
          // 不能大于下一行开始数字
          if (num > numrt2) {
            this.priceList[index].endNum = ''
            this.$antdMessage.info('不能大于下一行开始数字')
            return
          }
          // 不能小于开始数字
          if (num < numrt1) {
            this.priceList[index].endNum = ''
            this.$antdMessage.info('不能小于开始数字')
            return
          }
        } else { // 不存在下一行时的结束数字限制
          // 不能小于开始数字
          if (num < numrt1) {
            this.priceList[index].endNum = ''
            this.$antdMessage.info('不能小于开始数字')
            return
          }
        }
      }
    },
    handleAdd() {
      let goon = []
      console.log(this.priceList);
      for (let i = 0; i < this.priceList.length; i++) {
        const p = this.priceList[i];
        for (let key in p) {
          if (!!p[key] || p[key] === 0) {
          
          } else {
            goon.push(false)
          }
        }
      }
      if (goon.length > 0) {
        this.$antdMessage.info('请先填写完整再继续新增！')
      } else {
        this.priceList.push({
          startNum: '',
          endNum: '',
          qualifiedPrice: '0',
          notQualifiedPrice: '0',
        })
      }
    },
    deleteRecord(i) {
      if (i == 0 && this.priceList.length == 1) {
        return
      } else {
        this.priceList.splice(i, 1)
      }
    },
    setClass(i) {
      if (i == 0 && this.priceList.length == 1) {
        return 'del-text-disabled'
      } else {
        return 'btn-text'
      }
    },
    changeRadio(e) {
      this.showRegular = e.target.value == 'regular'
      if (this.showRegular) {
        this.$nextTick(() => {
          this.form.setFieldsValue({
            notQualifiedPrice: '0',
            qualifiedPrice: '0'
          })
        })
      } else {
        this.priceList = [{
          startNum: '',
          endNum: '',
          qualifiedPrice: '0',
          notQualifiedPrice: '0',
        }]
      }
    },
    openItProcess() {
      let par = {
        list: '/mess/messProductProcess/getDictPageList',
        visible: true, //弹窗开启
        title: '工序', //标题名称
        multi: false, //是否多选
        columns: this.columnsProcess, //表格配置
        value: this.processValue, //需要回显的数据，如：id:'12323213,321312312,321312312'
        valueKey: 'id', //需要拿到数据的key，如：id，userId等
        text: this.processText, //回显的中文，如：'张三'
        textKey: 'processName', //回显的中文key
      }
      this.$refs.tableSelectProcess.getInit(par)
    },
    // 选择工序回调
    getSelectValueProcess(id,text, item) {
      this.indexProcess += 1 //重置组件去除表格默认勾选数据，让自己赋值的数据回显（重要！！！）
      if (!id) {
        this.processChange()
        return
      }
      this.selectProcess(id, item[0])
    },
    processChange() {
      this.form.setFieldsValue({
        processName: '',
        processWorkUnitText: ''
      })
      this.processValue = ''
      this.processText = ''
    },
    selectProcess(v, good) {
      this.processValue = v
      this.processText = good.processName
      this.form.setFieldsValue({
        processName: `${good.processCode}-${good.processName}`,
        processWorkUnitText: good.processWorkUnitText
      })
    },
    // 搜索工序
    searchProcess() {
      this.$refs.tableSelectProcess.searchQuery(this.filterFormProcess)
    },
    // 重置搜索工序
    searchResetProcess() {
      this.filterFormProcess = {}
      this.$refs.tableSelectProcess.searchReset()
    },
    // 点击选择商品下拉框，弹出选择组件
    showSelect() {
      let par = {
        list: '/wms/goods/list',
        visible: true, //弹窗开启
        title: '物料', //标题名称
        multi: false, //是否多选
        columns: this.selectColumns, //表格配置
        value: this.goodsId || '', //需要回显的数据，如：id:'12323213,321312312,321312312'
        valueKey: 'id', //需要拿到数据的key，如：id，userId等
        text: this.goodsName || '',//回显的中文，如：'张三'
        textKey:'goodsName',//回显的中文key
      }
      this.$refs.tableSelect.getInit(par)
    },
    // 选择产品回调
    getSelectValue(id,text, item) {
      this.selectIndex += 1 //重置组件去除表格默认勾选数据，让自己赋值的数据回显（重要！！！）
      if (!id) {
        this.selectChange()
        return
      }
      this.selectGood(id, item[0])
    },
    selectChange() {
      this.form.setFieldsValue({
        goodsName: '',
        spec: '',
        basicUnitText: '',
      })
      this.goodsId = ''
      this.goodsName = ''
    },
    selectGood(v, good) {
      this.selectIndex += 1 //重置组件去除表格默认勾选数据，让自己赋值的数据回显（重要！！！）
      console.log(good);
      this.goodsId = v
      this.goodsName = good.goodsName
      this.form.setFieldsValue({
        goodsName: `${good.goodsCode}-${good.goodsName}`,
        basicUnitText: good.basicUnitText,
        spec: good.spec
      })
    },
    // 重置产品
    searchResetGoods() {
      this.filterForm = {}
      this.$refs.tableSelect.searchReset()
    },
    // 筛选产品
    searchGoods() {
      this.$refs.tableSelect.searchQuery(this.filterForm)
    },
    /* 面包屑返回 */
    goBack() {
      this.jkeForm.visible = false
    },
    /* 获取编辑详情 */
    initForm(id) {
      Object.assign(this.$data, this.$options.data.call(this));
      this.jkeForm.visible = true
      this.queryId = id
      if (id) {
        this.jkeForm.title = '编辑'
        this.submitApi = API.messProductProcessPriceEdit
        this.isEdit = true
        API.messProductProcessPriceQueryById({id}).then((res) => {
          if (res.code == 200) {
            let formObj = res.result
            formObj.processWorkUnitText = formObj.processWorkUnit || '-'
            formObj.spec = formObj.goodsSpec || '-'
            formObj.basicUnitText = formObj.basicUnit || '-'
            formObj.processName = formObj.processShowName
            formObj.goodsName = formObj.goodsShowName
            this.goodsId = formObj.goodsId
            this.goodsName = formObj.goodsName
            this.processValue = formObj.processId
            this.processText = formObj.processName
            this.showRegular = formObj.type == 'regular'
            API.queryMessProductProcessPriceDetailsByMainId({id}).then((p) => {
              if (p.code == 200) {
                if (this.showRegular) {
                  this.form.setFieldsValue({
                    notQualifiedPrice: p.result[0].notQualifiedPrice,
                    qualifiedPrice: p.result[0].qualifiedPrice
                  })
                } else {
                  this.priceList = p.result.map(pitem => {
                    return {
                      startNum: pitem.startNum,
                      endNum: pitem.endNum,
                      qualifiedPrice: pitem.qualifiedPrice,
                      notQualifiedPrice: pitem.notQualifiedPrice,
                    }
                  })
                }
              }
            })
            this.form.setFieldsValue(formObj)
          }
        })
      } else {
        this.form.setFieldsValue({
          type: 'regular',
          notQualifiedPrice: '0',
          qualifiedPrice: '0'
        })
        this.jkeForm.title = '新建'
      }
    },
    handleSubmit() {
      this.form.validateFields((err, values) => {
        if (!err) {
          let parameters = { ...values }
          parameters.processId = this.processValue
          parameters.goodsId = this.goodsId
          if (parameters.type == "regular") {
            parameters.messProductProcessPriceDetailsList = [{
              notQualifiedPrice: parameters.notQualifiedPrice,
              qualifiedPrice: parameters.qualifiedPrice
            }]
          } else {
            let arr = JSON.parse(JSON.stringify(this.priceList))
            for (let i = 0; i < arr.length; i++) {
              const item = arr[i];
              if (!item.notQualifiedPrice && item.notQualifiedPrice != '0' || !item.qualifiedPrice && item.qualifiedPrice != '0' || !item.startNum && item.startNum != '0' || !item.endNum && item.endNum != '0') {
                this.$antdMessage.warning('计件单价信息必填项未填！')
                return
              }
              arr[i].serialNo = i + 1
            }
            parameters.messProductProcessPriceDetailsList = arr
          }
          console.log(parameters);
          if (this.isEdit) {
            parameters.id = this.queryId
          }
          this.loadingSubmit = true
          this.submitApi(parameters).then((res) => {
            this.loadingSubmit = false
            if (res.code == 200) {
              let subMsg = this.isEdit ? '编辑计件单价成功！' : '新建计件单价成功！'
              this.$antdMessage.success(subMsg)
              this.$emit('refresh')
              this.goBack()
            } else {
              this.$antdMessage.warning(res.message)
            }
          })
        }
      })
    },
  },
}
</script>
<style scoped lang="less">
@import '~@/assets/less/public.less';
/deep/.ant-form-vertical {
  display: flex;
  justify-content: space-between;
  .ant-form-item {
    width: 30%;
  }
}
.form-body {
  height: calc(100vh - 120px);
  overflow-y: scroll;
}
.code-btn {
  position: absolute;
  right: 0;
  top: -34.5px;
}
</style>
